package models

import (
	"context"
	"github.com/micro/go-micro/v2/metadata"
	"kop/libs/database"
	"kop/modules/item/entity"
)

func Log(ctx context.Context, roleID, itemID, before, after int32) {

	source, _ := metadata.Get(ctx, "Source")

	database.DB.Create(&entity.ItemLog{
		RoleID: roleID,
		ItemID: itemID,
		Num:    after - before,
		Before: before,
		After:  after,
		Source: source,
	})
}
